Imports System
Imports System.Reflection
Imports System.Collections.Specialized
Imports System.Collections.ObjectModel
Imports System.Collections
Imports System.Text
Imports System.Configuration

Class cAppSettings

    Shared Sub UpdateAppSettings()

        Dim config As System.Configuration.Configuration = ConfigurationManager.OpenExeConfiguration(Assembly.GetEntryAssembly().Location)
        Dim newKey As String
        Dim newValue As String

        config.AppSettings.Settings.Clear()

        '->[DATABASE]
        newKey = "DataProviderType"
        newValue = "Access"
        config.AppSettings.Settings.Add(newKey, newValue)

        newKey = "ConnectionString"
        newValue = "'Provider=Microsoft.Jet.OLEDB.4.0;Data Source='C:\Users\Philippe\Documents\Visual Studio 2005\Projects\GXBMC\GXBMC\bin\Debug\GXBMC.mdb''"
        config.AppSettings.Settings.Add(newKey, newValue)

        config.Save(ConfigurationSaveMode.Modified)

        ' Force a reload of the changed section.
        ConfigurationManager.RefreshSection("appSettings")

    End Sub

    Shared Sub LoadAppSettings(ByRef pConfigurations As cConfigurations)

        Dim config As System.Configuration.Configuration = ConfigurationManager.OpenExeConfiguration(Assembly.GetEntryAssembly().Location)
        Dim appSettingSection As AppSettingsSection = CType(config.GetSection("appSettings"), AppSettingsSection)
        Dim appSettings As NameValueCollection = ConfigurationManager.AppSettings

        With pConfigurations

            '->[SOURCE]
            '.PathSourceCallXfr = appSettings.Get("PathSourceCallXfr")

        End With

    End Sub

End Class
